﻿/****************************** Module Header ******************************\
 * Module Name:  LinkLiteral.cs
 * Module Version:  1.0.0 (2012-9-17)
 * Copyright (c) AnyEB.Com (14507247@qq.com)
 * 
 * This class is used for LinkLiteral.
 * 
 * This source is subject to the GPL License.
 * See http://www.gnu.org/licenses/gpl.html.
 * All other rights reserved.
 * 
 * THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, 
 * EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED 
 * WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
\***************************************************************************/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace UCF.Core.Web
{
    public class LinkLiteral
    {
        private Dictionary<string, string> dict = new Dictionary<string, string>();
        private static LinkLiteral instance;
        public static LinkLiteral New()
        {
            if (instance == null) instance = new LinkLiteral();
            return instance;
        }
        public LinkLiteral Add(string name, string url, string attr="")
        {
            this.dict[name]=url;
            return instance;
        }
        public override string ToString()
        {
            StringBuilder sb = new StringBuilder();
            foreach (string s in dict.Keys)
            {
                sb.AppendFormat("<a href=\"{0}\">{1}</a>", dict[s], s);
            }
            return sb.ToString();
        }
    }
}
